body {
    font-family: 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
}

.upload-box {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.upload-box input[type="file"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.upload-box button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.upload-box button:hover {
    background-color: #2980b9;
}

.instructions {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.instructions h3 {
    margin-top: 0;
    color: #2c3e50;
}

/* 打印页面样式 */
.print-button {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 1000;
}

.a4-page {
    width: 210mm;
    min-height: 297mm;
    margin: 10mm auto;
    padding: 20mm;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    position: relative;
    page-break-after: always;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 15px;
}

.info-box {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
}

.info-item {
    text-align: center;
}

.label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.value {
    font-size: 18px;
    color: #e74c3c;
}

.qr-code {
    text-align: center;
    margin: 20px 0;
}

.qr-code img {
    width: 150px;
    height: 150px;
    border: 1px solid #ddd;
    padding: 5px;
    background: white;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.detail-table th, .detail-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

.detail-table th {
    background-color: #3498db;
    color: white;
}

.detail-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.footer {
    position: absolute;
    bottom: 20mm;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 14px;
    color: #7f8c8d;
}

@media print {
    body {
        background: none;
        margin: 0;
        padding: 0;
    }

    .print-button {
        display: none;
    }

    .a4-page {
        box-shadow: none;
        margin: 0;
        padding: 20mm;
    }
}
/* 添加横向布局样式 */
.a4-page {
    width: 297mm;
    height: 210mm;
    margin: 10mm auto;
    padding: 5mm;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    page-break-after: always;
}

.header {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.title-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-section h1 {
    margin: 0;
    font-size: 28px;
    color: #2c3e50;
}

.info-box {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.info-item {
    display: flex;
    min-width: 150px;
}

.label {
    font-weight: bold;
    margin-right: 5px;
    min-width: 70px;
}

.value {
    color: #e74c3c;
    font-weight: bold;
}

.qr-code {
    text-align: center;
    padding: 5px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.qr-code img {
    width: 80px;
    height: 80px;
}

.qr-code p {
    margin: 5px 0 0;
    font-size: 12px;
    color: #7f8c8d;
}

.table-container {
    flex: 1;
    overflow: hidden;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 16px;
}

.detail-table th {
    background-color: #3498db;
    color: white;
    padding: 8px 5px;
    text-align: center;
    position: sticky;
    top: 0;
}

.detail-table td {
    border: 1px solid #000000;
    padding: 6px 4px;
    text-align: center;
    word-wrap: break-word;
}

.detail-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.footer {
    text-align: center;
    padding-top: 10px;
    margin-top: auto;
    font-size: 12px;
    color: #7f8c8d;
    border-top: 1px solid #eee;
}

/* 打印按钮样式 */
.print-button {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 1000;
    font-size: 16px;
}

@media print {
    .a4-page {
        min-height: 210mm;
        padding: 5mm !important;
        height: 207mm;  /* 保留3mm出血位 */
    }
    
    .detail-table {
        font-size: 9px !important;
        line-height: 1.1;
    }
    
    .detail-table th,
    .detail-table td {
        padding: 3px 2px !important;
    }
    
    .header {
        margin-bottom: 5px;
        padding-bottom: 5px;
    }
}

.table-container {
    max-height: 150mm;  /* 增加表格高度，减少汇总区域 */
    overflow: hidden;
}

/* 物料汇总样式 */
.material-summary {
    margin-top: 5px;
    padding: 5px;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
    max-height: 40mm;
    overflow-y: auto;
    justify-items: center;
    max-width: 80%;
    margin: 0 auto;
}

.summary-item {
    display: flex;
    align-items: center;
    padding: 3px 6px;
    background-color: transparent;
    font-size: 11px;
    width: 100%;
    justify-content: center;
}

.material-code {
    font-weight: bold;
    color: #e74c3c;
    text-align: center;
    white-space: nowrap;
}

@media print {
    .material-summary {
        background-color: transparent !important;
        border: none !important;
        margin-top: 3px !important;
        padding: 3px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .summary-grid {
        max-height: 35mm;
        gap: 3px !important;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        justify-items: center !important;
        max-width: 85% !important;
        margin: 0 auto !important;
    }
    
    .summary-item {
        font-size: 9px !important;
        padding: 2px 4px !important;
        background-color: transparent !important;
        border: none !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    .material-code {
        text-align: center !important;
        white-space: nowrap !important;
    }
}